﻿using Bmz.IM.Communication;
using Bmz.Infrastructure.Util;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bmz.IM.Client
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            string AddressIP = string.Empty;
            foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
                {
                    AddressIP = _IPAddress.ToString();
                }
            }
            IPAddress[] ips = Dns.GetHostAddresses("");
            int port = PortUtil.GetLeisurePort(int.Parse(ConfigurationManager.AppSettings["LocalPort"]));
            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(AddressIP), port);
            ClientEngineContext.Current.Initialize(ipEndPoint);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginForm());
        }
    }
}
